use dioxus::{prelude::*};
const MAIN_CSS: Asset = asset!("/assets/main.css");
fn main() {
dioxus::launch(App);
}
#[component]
fn App() -> Element {
rsx! {
document::Link { rel: "stylesheet", href: MAIN_CSS }
Menu {}
}
}
#[component]
pub fn Menu() -> Element {
rsx! {
button { id: "push" }
}
}
#Getting css working in my first Dioxus project
1 messages · Page 1 of 1 (latest)
body {
background: red !important;
}```
What the app looks like: which also seems wrong.
the layout:
Are you running with dx serve?
Does your Dioxus CLI version match your Dioxus version?
yep
no
that fixed it
thank you
Excellent. We're hoping to make it less picky in future, but atm even the patch version should match.
ahh I see
I have another question, do you understand why my border is doing this?
you see how its 50% black, 50% grey. Why is the border not all grey.
body {
background: #fafafa;
color: #ffffff;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 20px;
}
#menu {
margin: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.button {
padding: 12px 28px;
font-size: 18px;
font-weight: 600;
color: #181818;
background-color: #ffffff;
border-radius: 16px;
border: 2px solid #dddddd;
cursor: pointer;
appearance: none;
pointer-events: auto;
transition:
background-color 0.15s ease,
}
.button:hover {
background-color: #2463eb;
}
use dioxus::{prelude::*};
const MAIN_CSS: Asset = asset!("/assets/main.css");
fn main() {
dioxus::launch(App);
}
#[component]
fn App() -> Element {
rsx! {
document::Link { rel: "stylesheet", href: MAIN_CSS }
Menu {}
}
}
#[component]
pub fn Menu() -> Element {
rsx! {
div {
id: "menu",
button { class: "button", "Push" }
}
}
}
Not sure. Could be the <button> element's default styling not being overriden entirely.
Does it happen with <div>?
I just closed and relaunched dx serve and it fixed
I'm quite confused on how this dx serve works
can you post your dioxus.toml?
sure
[application]
[web.app]
# HTML title tag content
title = "test"
# include `assets` in web platform
[web.resource]
# Additional CSS style files
style = []
# Additional JavaScript files
script = []
[web.resource.dev]
# Javascript code file
# serve: [dev-server] only
script = []```
It has a hot reloading mechanism. But you should probably treat that as not 100% reliable.
I think you should explicitly define a public dir
or wait no that's another issue
I see, thank you
well I managed to fix the issue i had now