File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
src/stories/Library/Forms/checkbox Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,13 @@ Unchecked.args = {
4646 validation : "Error error error" ,
4747} ;
4848
49+ export const hiddenLabel = Template . bind ( { } ) ;
50+ hiddenLabel . args = {
51+ isChecked : true ,
52+ label : "Checkbox" ,
53+ hiddenLabel : true ,
54+ } ;
55+
4956// Show multiple checkboxes to make it easier to test keyboard navigation.
5057const Several : ComponentStory < typeof Checkbox > = ( args ) => (
5158 < >
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ export type CheckboxProps = {
66 ariaLabel ?: string ;
77 validation ?: string ;
88 callback ?: ( isChecked : boolean ) => void ;
9+ hiddenLabel : boolean ;
910} ;
1011
1112export const Checkbox : React . FC < CheckboxProps > = ( {
@@ -14,6 +15,7 @@ export const Checkbox: React.FC<CheckboxProps> = ({
1415 ariaLabel,
1516 callback,
1617 validation,
18+ hiddenLabel = false ,
1719} ) => {
1820 const checkboxId = useRef ( `checkbox_id__${ Math . random ( ) } ` ) ;
1921 const [ checked , setChecked ] = useState ( isChecked ) ;
@@ -50,7 +52,11 @@ export const Checkbox: React.FC<CheckboxProps> = ({
5052 </ span >
5153 < div >
5254 { label && (
53- < span className = "checkbox__text text-small-caption color-secondary-gray" >
55+ < span
56+ className = { `checkbox__text text-small-caption color-secondary-gray ${
57+ hiddenLabel ? "checkbox__text--hide-visually" : ""
58+ } `}
59+ >
5460 { label }
5561 </ span >
5662 ) }
You can’t perform that action at this time.
0 commit comments