Skip to content
Open
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ type OTPInputProps = {
// }
// }`
noScriptCSSFallback?: string | null

// If you are using a Content-Security-Policy (CSP) with the `style-src` directive, you may need to
// specify a nonce value for the inline style tag.
nonce?: string
}
```

Expand Down
2 changes: 2 additions & 0 deletions packages/input-otp/src/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const OTPInput = React.forwardRef<HTMLInputElement, OTPInputProps>(
pasteTransformer,
containerClassName,
noScriptCSSFallback = NOSCRIPT_CSS_FALLBACK,
nonce,

render,
children,
Expand Down Expand Up @@ -173,6 +174,7 @@ export const OTPInput = React.forwardRef<HTMLInputElement, OTPInputProps>(
if (!document.getElementById('input-otp-style')) {
const styleEl = document.createElement('style')
styleEl.id = 'input-otp-style'
if (nonce) styleEl.setAttribute('nonce', nonce)
document.head.appendChild(styleEl)

if (styleEl.sheet) {
Expand Down
2 changes: 2 additions & 0 deletions packages/input-otp/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ type OTPInputBaseProps = OverrideProps<
containerClassName?: string

noScriptCSSFallback?: string | null

nonce?: string
}
>
type InputOTPRenderFn = (props: RenderProps) => React.ReactNode
Expand Down