Skip to content

Commit

Permalink
Chore/add field styles for number input (#823)
Browse files Browse the repository at this point in the history
* chore: add merge input styles for numberinput

* chore: update NumberINput stores

* chore: fix lint

* chore: remove merge as sx has higher priority
  • Loading branch information
joyce-foo authored Dec 16, 2024
1 parent dfe6aa8 commit 0f307e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/camp/src/NumberInput/NumberInput.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,9 @@ export const FormInput: StoryFn<NumberInputProps> = (args) => {
</FormControl>
)
}

export const InputStyles = Template.bind({})
InputStyles.args = {
placeholder: 'Pass in input styles',
inputStyles: { bgColor: 'gray.100' },
}
9 changes: 8 additions & 1 deletion packages/camp/src/NumberInput/NumberInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { useRef } from 'react'
import {
Box,
chakra,
ComponentWithAs as _,
Divider,
forwardRef,
NumberInputProps as ChakraNumberInputProps,
SystemStyleObject,
useFormControlProps,
useMergeRefs,
useMultiStyleConfig,
Expand All @@ -29,6 +29,11 @@ export interface NumberInputProps extends ChakraNumberInputProps {
* Whether to show the increment and decrement steppers. Defaults to true.
*/
showSteppers?: boolean

/**
* Merge styles for inner input field
*/
inputStyles?: SystemStyleObject
}

export const NumberInput = forwardRef<NumberInputProps, 'input'>(
Expand All @@ -38,6 +43,7 @@ export const NumberInput = forwardRef<NumberInputProps, 'input'>(
clampValueOnBlur = false,
isSuccess,
isPrefilled,
inputStyles,
...props
},
ref,
Expand Down Expand Up @@ -90,6 +96,7 @@ export const NumberInput = forwardRef<NumberInputProps, 'input'>(
// is this input.
ref={inputRef}
__css={styles.field}
sx={inputStyles}
/>
{showSteppers && (
<Box __css={styles.stepperWrapper} ref={stepperWrapperRef}>
Expand Down

0 comments on commit 0f307e2

Please sign in to comment.