Components Forms

Bar controls

Compact controls for options bars: Segmented, Choice, Checkbox, Hint, BarSeparator.

import { Segmented, Choice, Checkbox, Hint, BarSeparator } from '@kition/tessera-ui'

Props

What is shown
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
bar-controls.tsx
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).

PropTypeDefaultDescription
labelrequiredstring—The group's accessible name (for example "Selection mode").
valuerequiredV—
segmentsrequiredreadonly Segment<V>[]—
disabledboolean—
onChangerequired(value: V) => void—
testIdstring—Each button's test id is ${testId}-${value}.

Choice

A drop-down choice with its label before it.

PropTypeDefaultDescription
labelrequiredstring—
quietboolean—Draws no visible label (the drop-down still has label as its name).
valuerequiredV—
choicesrequiredreadonly (readonly [V, string])[]—
disabledboolean—
onChangerequired(value: V) => void—
testIdstring—

Checkbox

A check box with its label.

PropTypeDefaultDescription
labelrequiredReactNode—
checkedbooleanfalse
disabledboolean—
onChange(checked: boolean) => void—
testIdstring—
idstring—

Hint

A muted usage hint in a row.

PropTypeDefaultDescription
childrenrequiredReactNode—
testIdstring—

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