Foo
Bar
Span
Selected item: null
npx github-download-directory carllosnc/react-thekit src/components/Selectable
import { Selectable, SelectableItem } from '@/components'
import { Selectable, SelectableItem } from '@/components'
import { useState } from 'react'
function App() {
const [data, setData] = useState<string>(null)
return (
<Selectable
start={1}
onSelect={data => {
setData(data)
}}
>
<SelectableItem data={'foo'}>
<p> Foo </p>
</SelectableItem>
<SelectableItem data={'bar'}>
<p> Bar </p>
</SelectableItem>
<SelectableItem data={'span'}>
<p> Span </p>
</SelectableItem>
</Selectable>
)
}
name | type | default | description |
---|---|---|---|
children | SelectableItem | undefined | wrapper to make blocks selectables |
start | number(1-n) | -1 (no match any index) | index to start selected |
onSelect | (data: any) => void | undefined | event to select data |
name | type | default | description |
---|---|---|---|
data | any | undefined | data to be selected |