react-select 라이브러리 수정

This commit is contained in:
김창수 2025-01-22 18:03:46 +09:00
parent 2093c5ada3
commit 662bdd413b
2 changed files with 39 additions and 1 deletions

View File

@ -33,9 +33,32 @@ export default function ReactSelect(){
} }
} }
const CustomOption = (props) => {
const { data, innerRef, innerProps, isSelected, isFocused, isDisabled } = props;
const customClass = data.value === '6' ? 'special-option' : '';
// /
const optionClass = `${customClass} ${isSelected ? 'custom__option--is-selected' : ''}
${isFocused ? 'custom__option--is-focused' : ''}
${isDisabled ? 'custom__option--is-disabled' : ''}`;
return (
<div
ref={innerRef}
{...innerProps}
className={`custom__option ${optionClass}`}
>
{data.label}
</div>
);
};
return( return(
<Select <Select
ref={ref} ref={ref}
instanceId="react-select-unique-id"
className='react-select-custom' className='react-select-custom'
classNamePrefix='custom' classNamePrefix='custom'
options={selectOption} options={selectOption}
@ -44,6 +67,7 @@ export default function ReactSelect(){
placeholder="敬称選択" placeholder="敬称選択"
isClearable={true} isClearable={true}
menuPlacement={'auto'} menuPlacement={'auto'}
components={{Option: CustomOption}}
// isDisabled={true} // isDisabled={true}
/> />
) )

View File

@ -912,10 +912,23 @@ input[type=text]{
font-size: 13px; font-size: 13px;
padding: 7px 10px; padding: 7px 10px;
color: #45576F; color: #45576F;
} }
.custom__option--is-selected{ .custom__option--is-selected{
background-color: #2684FF;
color: #fff !important;
&.custom__option--is-focused{
background-color: #2684FF;
color: #fff; color: #fff;
} }
}
.custom__option--is-focused{
background-color: #DEEBFF;
color: #45576F;
}
.special-option{
color: red;
}
// disable // disable
&.custom--is-disabled{ &.custom--is-disabled{
.custom__control{ .custom__control{
@ -925,6 +938,7 @@ input[type=text]{
color: #999999; color: #999999;
} }
} }
} }
// toggle // toggle