4

I have a PrimeNG Menubar component, I want my items in the right side, they are currently on the left side, how could I align them to the right? In this case I want to align all of them to the right, not just a specific one

<p-menubar [model]="items">
</p-menubar>
export class NavigationComponent implements OnInit {
  items: MenuItem[];

  constructor() { }

  ngOnInit(): void {
    this.items = [
      {
        label: 'Solicitudes (5)',
        icon: 'pi pi-fw pi-clock'
      },
      {
        label: 'FrankHesse',
        icon: 'pi pi-fw pi-user',
        items: [
          {
            label: 'Perfil',
            icon: 'pi pi-fw pi-user'
          },
          {
            label: 'Salir',
            icon: 'pi pi-fw pi-power-off'
          }
        ]
      }
    ];
  }

}

I tried modifying the styles.scss file in the following way

#mercadeoucab .p-menuitem{
    float: right !important;
}

mercadeoucab is the ID of my body in the index.html file, however it didn't do anything, how could I accomplish this?

Antikhippe
  • 6,316
  • 2
  • 28
  • 43
FlowMafia
  • 922
  • 2
  • 19
  • 37

2 Answers2

1

For me, I did it with the following CSS:

p-menubarsub{
    width: 100%;
    display: flex;
    justify-content: flex-end;
}

This will align all the items to the right, and will work well when collapsed. However, when collapsed, the sandwich menu will still show to the left, and if you also want it to go to the right, then add the following css:

 a.p-menubar-button{
    order: 3;
}
Ghadir
  • 507
  • 10
  • 21
-1

Try to override PrimeNG CSS this way:

::ng-deep .p-menubar {
  height: 50px;

  p-menubarsub {
    position: absolute;
    right: 40px;
  }
}

See demo

Antikhippe
  • 6,316
  • 2
  • 28
  • 43