Props
import { Segmented } from '@kition/tessera-ui'
import { useState } from 'react'
const [value, setValue] = useState("start")
<Segmented
label="Align"
segments={segments}
value={value}
onChange={setValue}
/>When to use
- A tool’s options above the canvas.
Examples
An options bar
Alt-drag to copy
import { useState } from 'react'
import { BarSeparator, Checkbox, Choice, Hint, Segmented } from '@kition/tessera-ui'
import { TextAlignCenterIcon, TextAlignEndIcon, TextAlignStartIcon } from '@kition/tessera-icons/react'
export default function Demo() {
const [align, setAlign] = useState<'start' | 'center' | 'end'>('start')
const [snap, setSnap] = useState(true)
const [mode, setMode] = useState<'normal' | 'multiply' | 'screen'>('normal')
return (
<div className="demo-row">
<Segmented
label="Alignment"
value={align}
onChange={setAlign}
segments={[
{ value: 'start', icon: TextAlignStartIcon, label: 'Left' },
{ value: 'center', icon: TextAlignCenterIcon, label: 'Center' },
{ value: 'end', icon: TextAlignEndIcon, label: 'Right' },
]}
/>
<BarSeparator />
<Choice label="Mode" value={mode} onChange={setMode} choices={[['normal', 'Normal'], ['multiply', 'Multiply'], ['screen', 'Screen']]} />
<Checkbox label="Snap" checked={snap} onChange={setSnap} />
<Hint>Alt-drag to copy</Hint>
</div>
)
}Props
Segmented
Buttons of which one is pressed: icons (selection modes, alignment) or words (24h, 7d, 30d).
| Prop | Type | Default | Description |
|---|---|---|---|
labelrequired | string | — | The group's accessible name (for example "Selection mode"). |
valuerequired | V | — | |
segmentsrequired | readonly Segment<V>[] | — | |
disabled | boolean | — | |
onChangerequired | (value: V) => void | — | |
testId | string | — | Each button's test id is ${testId}-${value}. |
Choice
A drop-down choice with its label before it.
| Prop | Type | Default | Description |
|---|---|---|---|
labelrequired | string | — | |
quiet | boolean | — | Draws no visible label (the drop-down still has label as its name). |
valuerequired | V | — | |
choicesrequired | readonly (readonly [V, string])[] | — | |
disabled | boolean | — | |
onChangerequired | (value: V) => void | — | |
testId | string | — |
Checkbox
A check box with its label.
| Prop | Type | Default | Description |
|---|---|---|---|
labelrequired | ReactNode | — | |
checked | boolean | false | |
disabled | boolean | — | |
onChange | (checked: boolean) => void | — | |
testId | string | — | |
id | string | — |
Hint
A muted usage hint in a row.
| Prop | Type | Default | Description |
|---|---|---|---|
childrenrequired | ReactNode | — | |
testId | string | — |
BarSeparator
A hairline between groups of controls in a row.
No props.
Used in
8 of Kition's 16 kits use these components.
Board
Cube
Design
Film
Photo
Sheet
Slide
Vector