Created
September 12, 2022 20:51
-
-
Save nautilytics/5dfe0a609bf8322a1a97e38f12bbac4e to your computer and use it in GitHub Desktop.
An example of using a custom theme to style a BaseWeb Input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
import { | |
Input as BaseInput, | |
StyledEndEnhancer as BaseStyledEndEnhancer, | |
StyledStartEnhancer as BaseStyledStartEnhancer, | |
} from 'baseui/input' | |
import type { InputProps } from './types'; | |
import { themedWithStyle as withStyle } from '../style-utils' | |
import { padding } from 'polished' | |
const StyledStartEnhancer = withStyle(BaseStyledStartEnhancer, ({ $theme }) => ({ | |
backgroundColor: 'transparent', | |
...padding('0px', $theme.sizing['xx-small'], '0px', '0px') | |
})); | |
const StyledEndEnhancer = withStyle(BaseStyledEndEnhancer, ({ $theme }) => ({ | |
backgroundColor: 'transparent', | |
...padding('0px', $theme.sizing['xx-small'], '0px', '0px') | |
})); | |
export const Input = (props: InputProps): JSX.Element => { | |
return ( | |
<BaseInput | |
overrides={{ | |
EndEnhancer: StyledEndEnhancer, | |
StartEnhancer: StyledStartEnhancer | |
}} | |
{...props} | |
/> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment