Blazor Shared CSS File

Currently, I have successfully implemented 2 pages in my Blazor app:

Login.razor located in the Auth folder

AddPerson.razor situated in the Profile directory

At this point, I have managed to integrate a CSS file specifically for the AddPerson.razor page.

My inquiry is centered around how I can utilize the same CSS file for both of these pages?

https://i.sstatic.net/JCbBH.png

Answer №1

One of the key benefits of utilizing the new .NET5 CSS isolation feature (by placing a css file "below" your razor file) is that the css remains exclusive to each page/component, resulting in simplified development and better organization within the specific component.

In case you need to include some shared css that should be accessible across your application, you can revert back to "the traditional method" by updating the global css file. In the Blazor templates, this would typically involve modifying wwwroot/css/site.css for server side or wwwroot/css/app.css for client side applications.

Answer №2

Apologies for the delayed response. I have the "Web Compiler" extension installed which allows creating a .scss file to import others for definitions and more.

https://i.sstatic.net/LP5b8.png

MessageView.razor.scss

@import "common.scss";

.bubble {
    border-radius: 5px;
    box-shadow: $bubbleShadow; 
...

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Determine the initial left position of a div element in CSS prior to applying

Scenario : const display = document.querySelector('.display'); const container = document.querySelector('.outer-div'); document.addEventListener("click", (event) => { if (!event.target.closest("button")) return; if(event ...

I'm having an issue where my footer is getting cut off when I resize the browser and start side scrolling. Can

I designed a webpage with a footer that contains another div holding centered content. The footer is supposed to span the entire width, while the inner content div is set to 960px with a margin auto to center it. <footer> <div class="footer-in ...

Troublesome Issue with ngAnimate and ngHide: Missing 'ng-hide-animate' Hook Class

I am working on a case where I need to add animation to a DOM object using the ngHide directive: Check out this example here Within this scenario, I have an array of JSON objects: $scope.items = [ {"key": 1, "values": []}, {"key": 2, "values": [ ...

Encountered a problem when converting a JSON message's datetime array into c# using Newtonsoft.Json

I am currently working with the Newtonsoft.Json library to parse JSON messages in C#. string json = @"{'SomeSchedule': [ { 'PeriodEnd': '2014-05-28', 'PeriodStart': '2014-02-28', ...

Enhance your PrimeVue experience with the power of Tailwind CSS

After installing PrimeVue, I encountered an issue where the component style was not working, but Tailwind CSS was functioning correctly. It seems that when I install Tailwind first, it works fine until I add Primevue's button component, which then cau ...

What is the process for sending JSON data using libcurl.net in C#?

I have been attempting to utilize libcurl.net in order to establish a connection with a server and retrieve the JSON data from it. However, instead of receiving the JSON data, I am getting "CURLE_OK" as a response. Below is the code I am using: Curl.Globa ...

AngularJS - one-time execution of view generation from .NET controller

Currently, I have an MVC .NET application integrated with AngularJS. In my route provider configuration, I am utilizing the controllers of MVC to retrieve the views as shown below: .when('/Units', { templateUrl: 'Unit/Units' ...

Error encountered while trying to load the fonts

Upon attempting to load fonts into the Spectacle boilerplate, I encountered the following error message: Failed to decode downloaded font: http://localhost:3000/assets/fonts/Overpass-Bold.ttf OTS parsing error: invalid version tag I've includ ...

How to Create a DataTable Responsive Feature Where All Columns Collapse on Click, Except the Last One?

I am currently utilizing the DataTables library to generate a responsive table. I am aiming to create a feature where all columns in the DataTable can toggle between collapse and expand states when clicked, with the exception of the last column. Below is a ...

Uniform widths of table cells when resizing and overflowing

I am working with a table that looks like the one below: +-----+-----+-----+-----+-----+-----+ | | | | | | | +-----+-----+-----+-----+-----+-----+ | | | | | | | +-----+-----+-----+-----+-----+-----+ | | ...

Extract value from child div using JQuery and update text in another section of the page

Here is a fiddle showcasing the concept I am working on: https://jsfiddle.net/wvz9p3e7/1/ The code is written in PHP and involves a loop for cycling through 7 or 8 different garments. My goal is to have the window on the right side of the fiddle display t ...

What is the best way to ensure that all of my images are the same size?

I've been working on making my pictures of varying resolutions the same size here, but no matter what I try, it just doesn't seem to work. Here is what I'm getting: . When I change the state to 1, 2, 3, or 4, I want it to look like this: her ...

Random image generator using jQuery on the home page body

Hey guys, I'm working on a cool feature for my Wordpress site where a random background image loads every time the homepage is refreshed. Check out the code snippets below: First, here's what I have in my style sheet (style.css): body.home { ...

What is the process for adding null values to a database?

Hey there, I'm attempting to insert a null value into a database column based on a gridview datakeys value. So if the data is "", I want to insert null into the database. The problem is, I keep getting a space ' ' in the database column inst ...

html5 Showing and hiding div elements

Here is a snippet of code to consider: @using App.Models @model App.Models.AllPeopleViewModel @{ ViewBag.Title = "Index"; } <html> <head> </head> <body> @foreach (Customer person in Model.Content) { <div class=&qu ...

Modify the appearance of the username in the header after logging in with Yii

As a fellow coder using Yii, I'm seeking assistance in changing the style of my username displayed in the header upon login. Currently, it's appearing in black color and I desire it to be italicized-white. The code snippet below shows my header s ...

Finding the name of the file from a given path

There is a string value in the format of /Images/She.jpg. How can I extract and retrieve only the portion following /images/, specifically She.jpg? What would be the best method to accomplish this task? ...

Result of jQuery Ajax responseText: "An issue occurred while processing your request."

I encountered an issue with the UAT environment where I received the error message "There was an error processing the request". Interestingly, the code works fine in my local environment. The line Utility.WriteLogEvent("TestService", strMessage); is respo ...

What is causing the action button in my MUI snackbar to occupy an additional line?

I'm currently learning how to use MUI and I'm struggling with a specific issue. The close button in my code is appearing on a separate line, but I want it to be on the same line as the word "again". I've tried experimenting with absolute pos ...

SignalR enables the display of identical dashboard data pulled from queries on various browsers. By utilizing SignalR/hub, MVC, and C#.NET, the data can

Encountering an issue with my signalr/hub while fetching dashboard data. I'm using 2 browsers to access data based on dates. However, when searching for July on browser 1 and then switching to another month on browser 2, the data in browser 1 gets upd ...