mirror of
https://github.com/SteamFramelyHomebrew/framely.git
synced 2026-10-23 09:01:46 +02:00
9 lines
701 B
TypeScript
9 lines
701 B
TypeScript
import React from 'react';
|
|
export type SwitchProps={checked:boolean;label:string;disabled?:boolean;onChange:(checked:boolean)=>void;className?:string};
|
|
export function Switch({checked,label,disabled=false,onChange,className=''}:SwitchProps){
|
|
return <button type="button" className={`ui-switch ${checked?'on':''} ${className}`} role="switch" aria-checked={checked} aria-label={label} disabled={disabled} onClick={()=>onChange(!checked)}><span aria-hidden="true"/></button>;
|
|
}
|
|
export function SwitchRow({description,...props}:SwitchProps&{description?:string}){
|
|
return <div className="switch-row"><div><b>{props.label}</b>{description&&<small>{description}</small>}</div><Switch {...props}/></div>;
|
|
}
|