Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading