1

I am decently new to react and am now trying to add semantic ui to my website. Every time I try to load the components they show as regular html instead of how semantic ui is supposed to look.

Here is an example of a class I am exporting:

import React, { Component } from "react";
import {Radio} from 'semantic-ui-react';
const RadioExampleToggle = () => <Radio toggle />

class Contact extends Component {  
  render() {
    return (
      <div>
        <h2>DEMO PAGE</h2>
        <p>Just a demo.
        </p>
        {RadioExampleToggle()}
      </div>
    ); 
  }
}
export default Contact;

This will show up as a regular radio button which is what I find weird. How do I get it to display the semantic UI versions.

7
  • Is the css loaded in the site? Does anything look like Semantic UI? Can you confirm if the HTML looks like what SemanticUI html should look like? Commented Nov 12, 2019 at 15:11
  • Everything looks like plain HTML with no styling. Though the only part that should be styled would be the radio button to my knowledge, since its the only one loaded in Commented Nov 12, 2019 at 15:14
  • So the html doesn't have any classes that say stuff like 'ui ...' in it? Based on some cursory reading, it looks like semantic ui HTML has html with classes like class="ui active button" Commented Nov 12, 2019 at 15:15
  • Correct, regular semantic UI does. I did not use this. Here is an example of a button in react. react.semantic-ui.com/elements/button Just open in sandbox. It is the same type of way I am trying to do radio button Commented Nov 12, 2019 at 15:16
  • It is working fine! I think you haven't imported the cdn tag in public/index.html folder here is the working code link codesandbox.io/s/zen-spence-2yd1f?fontsize=14 Commented Nov 12, 2019 at 15:18

2 Answers 2

4

Please try import CSS file from semantic-ui.

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

Sign up to request clarification or add additional context in comments.

2 Comments

Hi, im using semantic ui react. not semantic UI. I installed it with yarn. Its why my code doesnt toss an error and still displayed a radio button. See here react.semantic-ui.com/usage
Yes. but after install, you will need to import css file manually. prntscr.com/pvygox
1

Try this:

Put it in your index.js

const styleLink = document.createElement("link");
styleLink.rel = "stylesheet";
styleLink.href = "https://cdn.jsdelivr.net/npm/semantic-ui/dist/semantic.min.css";
document.head.appendChild(styleLink);

Doing it this way will also help you when your app offers theme switching functionality.

code sample

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.