Skip to content

Instantly share code, notes, and snippets.

@timurista
Created May 4, 2018 13:31
Show Gist options
  • Save timurista/8e612e4e522025d082f01a4d0439b4cd to your computer and use it in GitHub Desktop.
Save timurista/8e612e4e522025d082f01a4d0439b4cd to your computer and use it in GitHub Desktop.
A11y code example
export const InvisibleInput = styled.input`
opacity: 0;
position: absolute;
cursor: pointer;
&:focus + ${RadioButton} {
box-shadow: 0 0 0 2px ${theme.colors.white},
0px 0px 0px 4px ${tint(0.35, theme.colors.teal)};
}
`;
export const RadioInput = ({
selected,
onClick,
label,
radioRight,
className,
}: Props) => (
<RadioWrapper className={className} align="center" mb={[2]}>
<Label radioRight={radioRight}>
<InvisibleInput
type="radio"
value={label}
onChange={onClick}
checked={selected}
autoFocus={selected}
/>
<RadioButton>{selected && <SelectedCircle />}</RadioButton>
<Box ml={radioRight ? 0 : 2}>{label}</Box>
</Label>
</RadioWrapper>
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment