Last active
January 6, 2022 10:10
-
-
Save hekystyle/78c76d4fc8ca15650569679ca7b31cb2 to your computer and use it in GitHub Desktop.
Extends Select from Ant design by suffix using styled components
This file contains hidden or 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 React, { VFC } from 'react'; | |
| import styled, { css } from 'styled-components'; | |
| import { Select as AntdSelect, SelectProps as AntdSelectProps } from 'antd'; | |
| import { SelectValue } from 'antd/lib/select'; | |
| export interface SelectProps extends AntdSelectProps<SelectValue> { | |
| suffix?: React.ReactElement; | |
| } | |
| const StyledSelect = styled(AntdSelect)<SelectProps>` | |
| .ant-select-selector { | |
| ${({ suffix }) => | |
| suffix && | |
| css` | |
| border-radius: 4px 0px 0px 4px !important; | |
| min-width: 85%; | |
| `} | |
| } | |
| `; | |
| export function Select(props: SelectProps): ReturnType<VFC> { | |
| const { suffix } = props; | |
| return ( | |
| <section style={{ display: 'flex' }}> | |
| <StyledSelect {...props} /> | |
| {suffix} | |
| </section> | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment