Skip to content

Commit

Permalink
feat(radio): add description field
Browse files Browse the repository at this point in the history
  • Loading branch information
apust committed Oct 23, 2020
1 parent ab9b3d3 commit 467fcf8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/packages/core/src/radio/Radio.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import { Radio } from '.';
<Radio name="radio1" label="Option 2" />
</Preview>

<Preview>
<Radio name="radio1" label="Option 1" description="Description 1" checked />
<Radio name="radio1" label="Option 2" description="Description 2" />
</Preview>

<Preview>
<Radio name="radio2" label="Option 1" checked readonly />
<Radio name="radio2" label="Option 2" readonly />
Expand Down
2 changes: 2 additions & 0 deletions src/packages/core/src/radio/Radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const Radio = forwardRef<HTMLInputElement, RadioProps>((props: RadioProps
const {
className,
defaultChecked,
description,
disabled = false,
id,
label,
Expand Down Expand Up @@ -38,6 +39,7 @@ export const Radio = forwardRef<HTMLInputElement, RadioProps>((props: RadioProps
<span className="_e_radio__icon" />
<span className="_e_radio__label">
{ label }
{ description && <span className="_e_radio__desc">{ description }</span> }
</span>
</label>
);
Expand Down
5 changes: 5 additions & 0 deletions src/packages/core/src/radio/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export interface RadioProps extends InputHTMLAttributes<HTMLInputElement> {
*/
defaultChecked?: boolean;

/**
* Radio description.
*/
description?: string;

/**
* Radio disabled state.
* @default false
Expand Down

0 comments on commit 467fcf8

Please sign in to comment.