Beginner information on layout element usage/guidelines? #858
-
I'm completely new to this framework so this question is from a beginner viewpoint. For context - I'm a long time C# dev with a bit of experience with ASP/MVC. Is there a document available that explains expected use of layout elements available to us? I'm specifically thinking of equivalents to the Bootstrap system. There are pages about fluent UI on MS design but those are aspirational, not documentation :) Is there an equivalent to "container" that items must be in? Is there an equivalent to "row" that items should be nested within? FluentLayout doesn't have a width parameter so I assume it is supposed to be within elements like stack that do? I have rewritten the generated MainLayout.razor to use fluent elements, but I have not been able to get a working layout when using <FluentMainLayout ...> as the outer element. The element does not work as expected when I replace the asp element with it. For example, FluentMain is not documented that I can see. The small samples on each element page often have "stock" elements (like ) instead of using , instead of etc. - so I do not have very many references.I have a functional layout using the fluent grid, stack, and Layout elements but resizing, padding, and margins not always what I would expect without me adding some css - I'm assuming that I have nested elements improperly. Also - looking forward to the updated templates mentioned in github issues! Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 14 replies
-
Hi, There is no document available like that. As opposed to Bootstrap, we do not prescribe what elements you need to realize a layout. We just provide some of the building blocks to help you. I think the demo site describes all of these well enough. Specifically https://www.fluentui-blazor.net/Layout shows a number of them working together. If things are unclear, there is always the source of the components themselves, but also the source of the the demo site is available in the repo. I think some examples have gone missing from your post We kind of assume you to know css and html to make a layout look, act and behave as you want. We don't aim to cater every possible scenario with the components. Yes, we (main maintainers) work for Microsoft and yes we implement Fluent in these Blazor components, but we are not an integral part of the Fluent team in Microsoft. Not everything they publish pertains to our library per se. Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
There's a good post Getting started with Blazor and FluentUI that is helpful. It covers how to do responsive layouts which I think a lot of people coming from Bootstrap would want. I'm looking to replicate Navbar in Bootstrap, but NavMenu looks to be vertical only. I'm assuming I could use Menu instead? |
Beta Was this translation helpful? Give feedback.
-
This looks very good, thanks for being so responsive (pardon the pun, but it's Friday 😀) I like the enumeration design. @bytefish Since I've referenced your blog, do you have any thoughts? I noticed minor typos, showing "that" instead of "than", i.e. One final suggestion, can you think of a way to wrap the Javascript change event of window.matchMedia? I was thinking it would be helpful to register a C# event using an enumeration value for a breakpoint change. The post Using matchMedia shows more detail, but below is a simple example based on var mql = window.matchMedia('(max-width: 599px)');
mql.addEventListener('change', event => console.log(event.matches ? 'At or under' : 'Over', event.media)); |
Beta Was this translation helpful? Give feedback.
-
Tried it out with the JavaScript interoperability in Blazor var mql;
function registerEvent(dotNetObjRef, mq, init) {
mql = window.matchMedia(mq);
if (init)
dotNetObjRef.invokeMethodAsync("OnBreakpointChange", mql.matches, mql.media);
mql.addEventListener('change', event => dotNetObjRef.invokeMethodAsync('OnBreakpointChange', event.matches, event.media));
} The callback to C# worked and updated the variable for display @code
{
string Message;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
await JsRuntime.InvokeVoidAsync("registerEvent", DotNetObjectReference.Create(this), "(max-width: 599px)");
}
[JSInvokable]
public void OnBreakpointChange(bool match, string media)
{
Message = (match ? "At or under " : "Over ") + media;
StateHasChanged();
}
} It would be great if this could be wired up with the FluentGrid somehow. |
Beta Was this translation helpful? Give feedback.
Hi,
There is no document available like that. As opposed to Bootstrap, we do not prescribe what elements you need to realize a layout. We just provide some of the building blocks to help you. I think the demo site describes all of these well enough. Specifically https://www.fluentui-blazor.net/Layout shows a number of them working together.
If things are unclear, there is always the source of the components themselves, but also the source of the the demo site is available in the repo.
I think some examples have gone missing from your post
We kind of assume you to know css and html to make a layout look, act and behave as you want. We don't aim to cater every possible scenario with the com…