Skip to content

Commit

Permalink
fix: checkbox label (#172)
Browse files Browse the repository at this point in the history
- center align label children
- gap label children
  • Loading branch information
uipoet authored Jan 28, 2022
1 parent 0d6afcc commit 05fb321
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/docs/pages/examples/checkbox/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Card, Checkbox, useHashRef } from "ninjakit";
import { MdFavorite } from "react-icons/md";

import styles from "../examples.module.css";
import { CheckboxState, useButtonState } from "./state";
Expand All @@ -19,9 +20,11 @@ export function CheckboxExample() {
indeterminate={indeterminate}
label={
labelWithJSX ? (
<span>
Label <strong>with node</strong>
</span>
<>
<span>Label </span>
<strong>with </strong>
<MdFavorite />
</>
) : (
"Label"
)
Expand Down
7 changes: 7 additions & 0 deletions src/lib/components/checkbox/checkbox.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
position: relative;
}

.children {
align-items: center;
display: flex;
flex-wrap: nowrap;
gap: 0.4rem;
}

.check {
fill: var(--md-color-on-primary);
font-size: 2rem;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/checkbox/checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const Checkbox = forwardRef<
type="checkbox"
/>
<MdCheck className={styles.check} />
{children || label}
<span className={styles.children}>{children || label}</span>
</label>
{error && (
<div className={styles.errorMessage} role="tooltip">
Expand Down

0 comments on commit 05fb321

Please sign in to comment.