@dt-dds/react-button
v1.0.0-beta.105
Published
This component allows the user to take action, by clicking on it.
Downloads
5,864
Readme
Button Package
This component allows the user to take action, by clicking on it.
Button Usage
import { Button } from '@dt-dds/react-button';
export const App = () => {
const handleClick = () => null; //Some action here
return <Button onClick={handleClick}>Click me</Button>;
};Properties
| Property | Type | Default | Description |
| ------------ | ----------------------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| children | ReactNode | - | Child components to be rendered |
| onClick | function | - | The triggered function when clicked on the button |
| dataTestId | string | button | Customizable test identifier |
| isDisabled | boolean | false | Determines the disabled state of the button |
| variant | 'solid' \| 'outlined' \| 'text' | solid | Determines the variant of the button. solid button are for high-emphasys actions. outlined represent medium-emphasys actions. text represent low-emphasys actions. |
| color | 'primary' \| 'error' \| 'secondary'\| 'contrast' 'accent' | primary | Determines the color of the button. It is dependent on the variant. |
| style | React.CSSProperties | - | Gives the button some specific css properties |
| isLoading | boolean | - | If set to true, the button is disabled and a spinner is showed next to the label |
Variant and Colors
As mentioned in the props table, the colors are dependent on the variant. Here is the list of available colors for each available variant:
| Color\Variant | Solid | Outlined | Text |
| ------------- | ----- | -------- | ---- |
| primary | yes | yes | yes |
| secondary | yes | yes | yes |
| contrast | yes | - | - |
| accent | yes | yes | yes |
| error | yes | yes | yes |
Stack
- TypeScript for static type checking
- React — JavaScript library for user interfaces
- Emotion — for writing css styles with JavaScript
- Storybook — UI component environment powered by Vite
- Jest - JavaScript Testing Framework
- React Testing Library - to test UI components in a user-centric way
- ESLint for code linting
- Prettier for code formatting
- Tsup — TypeScript bundler powered by esbuild
- Yarn from managing packages
Commands
yarn build- Build the packageyarn dev- Run the package locallyyarn lint- Lint all files within this packageyarn test- Run all unit testsyarn test:report- Open the test coverage reportyarn test:update:snapshot- Run all unit tests and update the snapshot
Compilation
Running yarn build from the root of the package will use tsup to compile the raw TypeScript and React code to plain JavaScript.
The /dist folder contains the compiled output.
button
└── dist
├── index.d.ts <-- Types
├── index.js <-- CommonJS version
└── index.mjs <-- ES Modules version
...Versioning
Follows semantic versioning
© License
Licensed under MIT License
