Skip to content

Commit

Permalink
feat(FormControl.Label) add className prop (#5113)
Browse files Browse the repository at this point in the history
* add className to FormControl.Label

* add changeset
  • Loading branch information
randall-krauskopf authored Oct 14, 2024
1 parent bd2c988 commit c28378e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/angry-pants-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': minor
---

Add `className` prop to `FormControl.Label` component
5 changes: 4 additions & 1 deletion packages/react/src/FormControl/_FormControlLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ export type Props = {
requiredText?: string
requiredIndicator?: boolean
id?: string
className?: string
} & SxProp

const FormControlLabel: React.FC<
React.PropsWithChildren<{htmlFor?: string} & React.ComponentProps<typeof InputLabel> & Props>
> = ({as, children, htmlFor, id, visuallyHidden, requiredIndicator = true, requiredText, sx, ...props}) => {
> = ({as, children, htmlFor, id, visuallyHidden, requiredIndicator = true, requiredText, sx, className, ...props}) => {
const {disabled, id: formControlId, required} = useFormControlContext()

/**
Expand All @@ -26,6 +27,7 @@ const FormControlLabel: React.FC<
? {
as,
id,
className,
visuallyHidden,
required,
requiredText,
Expand All @@ -37,6 +39,7 @@ const FormControlLabel: React.FC<
: {
as,
id,
className,
visuallyHidden,
htmlFor: htmlFor || formControlId,
required,
Expand Down
3 changes: 3 additions & 0 deletions packages/react/src/internal/components/InputLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type BaseProps = SxProp & {
requiredIndicator?: boolean
visuallyHidden?: boolean
id?: string
className?: string
}

export type LabelProps = BaseProps & {
Expand All @@ -35,6 +36,7 @@ const InputLabel: React.FC<React.PropsWithChildren<Props>> = ({
visuallyHidden,
sx,
as = 'label',
className,
...props
}) => {
return (
Expand All @@ -45,6 +47,7 @@ const InputLabel: React.FC<React.PropsWithChildren<Props>> = ({
}
htmlFor={htmlFor}
id={id}
className={className}
sx={{
fontWeight: 'bold',
fontSize: 1,
Expand Down

0 comments on commit c28378e

Please sign in to comment.