@k8ordo/ui

CheckboxCard

選択肢をカードで見せる複数選択です。説明や図を添えて、選択肢を大きく見せたいときに使います。

インポート

ts
import { CheckboxCard } from '@k8ordo/ui';

使い方

Choose features to enable

tsx
import { CheckboxCard } from '@k8ordo/ui';
import { useState } from 'react';

const options = [
  {
    value: 'history',
    label: 'Version history',
    description: 'Keep every change and roll back when needed.',
  },
  {
    value: 'comments',
    label: 'Inline comments',
    description: 'Leave feedback directly on each section.',
  },
  {
    value: 'share',
    label: 'Share links',
    description: 'Publish read-only share links in seconds.',
  },
];

const [value, setValue] = useState(['comments']);

<p id="features-label">Choose features to enable</p>
<CheckboxCard
  disabled={false}
  invalid={false}
  aria-labelledby="features-label"
  onChange={setValue}
  options={options}
  value={value}
/>

既定値

Choose features to enable

tsx
const options = [
  {
    value: 'history',
    label: 'Version history',
    description: 'Keep every change and roll back when needed.',
  },
  {
    value: 'comments',
    label: 'Inline comments',
    description: 'Leave feedback directly on each section.',
  },
  {
    value: 'share',
    label: 'Share links',
    description: 'Publish read-only share links in seconds.',
  },
];

<p id="features-default-label">Choose features to enable</p>
<CheckboxCard
  defaultValue={['history', 'share']}
  disabled={false}
  invalid={false}
  aria-labelledby="features-default-label"
  options={options}
/>

Props

aria-labelledby
Type: string
Default: -
options
Type: readonly CheckboxCardOption[]
Default: -
defaultValue?
Type: string[]
Default: -
invalid?
Type: boolean
Default: false
onChange?
Type: (value: string[]) => void
Default: -
ref?
Type: Ref<HTMLFieldSetElement>
Default: -
value?
Type: string[]
Default: -
PropTypeDefault
aria-labelledbystring-
optionsreadonly CheckboxCardOption[]-
defaultValue?string[]-
invalid?booleanfalse
onChange?(value: string[]) => void-
ref?Ref<HTMLFieldSetElement>-
value?string[]-

継承する属性(内部で固定するものを除く): FieldsetHTMLAttributes<HTMLFieldSetElement>

k8ordo

Baselineに入った機能を、制限なく使うReactのライブラリ群。