Segmented Control is frequently used to let users toggle between different formatting or to filter, like a grid view and a table view.
npm install @dt-dds/react-segmented-controlSegmented Control is frequently used to let users toggle between different formatting or to filter, like a grid view and a table view.
``jsx
import { SegmentedControl } from '@dt-dds/react-segmented-control';
export const App = () => {
return (
showLabel={false}
onChangeControl={handleChanges}
>
value='gallery'
iconCode='grid_view'
disabled
/>
);
};
`
| Property | Type | Default | Description |
| ----------------- | ---------- | ------- | ------------------------------------------------------------ |
| selectedValue | string | - | sets the selected value, useful to fulfill the initial value |showLabel
| | boolean | false | makes the labels visible or not for all options |onChangeControl
| | function | - | callback function to receive the control value changed |dataTestId
| | string | - | sets the id for testing purposes |
| Property | Type | Default | Description |
| ---------- | --------- | ------- | ----------------------------------------------------------------------------- |
| label | string | - | sets the option label, visible when showLabel is true or the icon is missing |value
| | string | false | value to control the option |iconCode
| | Code | - | sets the code for the icon to be used, check the package from @dt-dds/icons |disabled
| | boolean | false | disables the option |
- 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
- 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
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.
`bash``
segmented-control
└── dist
├── index.d.ts <-- Types
├── index.js <-- CommonJS version
└── index.mjs <-- ES Modules version
...
Follows semantic versioning
Licensed under MIT License