Justify and attribute the use of any open source code that you use
What is the line between using open source code and writing the code by your own for completing an interview task?
There's no hard and fast line. It depends on what the interviewer is trying to assess.
A general advise in software development is to use tried and tested code. That's one of the crucial purposes of open sourcing code, i.e. not to reinvent the wheel every time.
However, here writing code is part of an interview task. There isn't a precise Yes/No answer to whether you should use open source code or not. But it tends towards Yes, if you can justify the use of it.
Think from the point of view of the interviewer. They are trying to assess your skills to get a task done. While one of the intent of getting a candidate to write code is to see their ability to write the solution for a problem, it's also an important skill to assess, how well they can identify and obtain pre written code to solve a problem.
There shouldn't be any problem in using an open source library or component, but it would be best to give proper attribution and reasoning why you chose to use it.
It is important for the interviewer to understand how well you understand the problem and the code that solves the problem, instead of writing the code yourself.
However, though process and intent can vary from interviewer to interviewer. You can propose the interviewer about using certain open source components along with the reasoning behind using them. Do it before starting the task. Some interviewers may be precisely looking for your skill to implement a certain functionality and may want you to write the code from scratch.