useCheckboxField
Reads the value of a checkbox field.
function useCheckboxField(props: {field: string}): boolean
Arguments
| Property | Type | Description |
|---|---|---|
| field | string | The name of the field. |
Returns
Whether the checkbox is checked. Returns false while the field has no value.
Example
src/widgets/example/Example.tsx
import React from 'react'
import {useCheckboxField} from '@modbros/dashboard-sdk'
export default function Example() {
const isBold = useCheckboxField({field: 'bold'})
return <span style={{fontWeight: isBold ? 'bold' : 'normal'}}>Text</span>
}