首页 > 其他 > 详细

利用styled-component修改Ant Design 样式

时间:2019-08-09 13:41:42      阅读:101      评论:0      收藏:0      [点我收藏+]

如果你搜索了这个问题,肯定也遇到了和我一样的困惑,又想用Ant Design的组件,有些样式自己又想使用styled-component修改,标签名冲突怎么办? 直接上代码把....

import React from ‘react‘;
import { Input, Button, List } from ‘antd‘; 
import { btnStyle, inputStyle, listStyle } from ‘./style‘

const TodoListUI = (props) => {
    return (
        <div style={{ margin: ‘20px‘ }}>
            <Input style={inputStyle}value={props.inputValue} onChange={props.handleInputChange} />
            <Button style={btnStyle}type="danger" onClick={props.handleBtnClick}>提交</Button>
            <List style={listStyle}bordered dataSource={props.list}
                renderItem={
                    (item, index) => <List.Item onClick={() => { props.handleItemDelete(index) }}>{item}</List.Item>}
            />
        </div>
    )
}
export default TodoListUI;

style.js (就是写css代码的文件)

import  styled  from ‘styled-components‘;

export const btnStyle = {
  background:‘pink‘
}
export const inputStyle={
    width:‘300px‘,
    margin:‘20px‘,
}
export const listStyle={
    width:‘300px‘,
    margin:‘20px‘,
}

现在大概知道怎么用了吧。在style.js文件里直接定义好你需要自定义的css代码,在UI组件里直接引入即可修改antd的原有样式。

 

利用styled-component修改Ant Design 样式

原文:https://www.cnblogs.com/jack-zhou21235/p/11326364.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!