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(
<Select
ref={ref}
instanceId="react-select-unique-id"
className='react-select-custom'
classNamePrefix='custom'
options={selectOption}
@ -44,6 +67,7 @@ export default function ReactSelect(){
placeholder="敬称選択"
isClearable={true}
menuPlacement={'auto'}
components={{Option: CustomOption}}
// isDisabled={true}
/>
)

View File

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