给所有select元素添加一个右侧下拉按钮

This commit is contained in:
PaRaD1SE98
2023-05-10 07:14:49 +00:00
parent 0ad91101a4
commit 96e3d3a22c
6 changed files with 70 additions and 15 deletions

View File

@@ -3,6 +3,7 @@ import LoadingIcon from "../icons/three-dots.svg";
import CloseIcon from "../icons/close.svg";
import EyeIcon from "../icons/eye.svg";
import EyeOffIcon from "../icons/eye-off.svg";
import DownIcon from "../icons/down.svg";
import { createRoot } from "react-dom/client";
import React, { HTMLProps, useEffect, useState } from "react";
@@ -244,3 +245,23 @@ export function PasswordInput(props: HTMLProps<HTMLInputElement>) {
</div>
);
}
export function Select(
props: React.DetailedHTMLProps<
React.SelectHTMLAttributes<HTMLSelectElement>,
HTMLSelectElement
>,
) {
const { className, children, ...otherProps } = props;
return (
<div className={styles["select-with-icon"]}>
<select
className={`${styles["select-with-icon-select"]} ${className}`}
{...otherProps}
>
{children}
</select>
<DownIcon className={styles["select-with-icon-icon"]} />
</div>
);
}