如何使用语义用户界面反应下拉列表

时间:2020-03-20 18:36:49

标签: reactjs forms dropdown semantic-ui semantic-ui-react

我正在尝试将语义UI响应与typescript一起使用来创建表单。所以我正在使用文档。但是,当我实现dropdow或表单时,我得到了没有CSS的基本HTML表单。我应该怎么做才能获得与react.semantic-ui.com相同的用户体验

import { Dropdown } from 'semantic-ui-react'
const options = [
   { key: 1, text: 'Location 1', value: 1 },
   { key: 2, text: 'Location 2', value: 2 },
   { key: 3, text: 'Location 3', value: 3 },
 ]

return (

    <Form>

       <div>
       <Dropdown
       placeholder='Etat *'
       title="Select Etat"
       fluid
       selection
       options={StatusOptions}
       />
       </div> 

</Form>

2 个答案:

答案 0 :(得分:1)

您需要使用npm npm i semantic-ui-css

安装默认主题。

然后将该主题导入您的app.tsindex.ts

import 'semantic-ui-css/semantic.min.css'

答案 1 :(得分:0)

类似于Fayeed的上述回答。您可以在index.html

的标题标签中导入CSS CDN。

例如:

<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css" />

相关问题